<!DOCTYPE html>
<html lang="en">
<head>
    <title>新增赔付记录</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <style>
        input.error {
            border: 1px solid #E6594E;
        }
    </style>
</head>
<body>
<div class="container">
    <form id="addPayBackForm" method="post" action="/payBack/addPayBack.do">
        <div class="form-group">
            <label for="caseId">案件编号：</label>
            <input type="text" class="form-control" id="caseId" name="cases.caseId" placeholder="输入案件编号"
                   value="${cases.caseId}">
        </div>
        <div class="form-group">
            <label for="payName">收款人：</label>
            <input type="text" class="form-control" id="payName" name="payName" placeholder="输入收款人"
                   value="${cases.order.user.sname}">
        </div>
        <div class="form-group">
            <label for="userCardId">身份证号：</label>
            <input type="text" class="form-control" id="userCardId" name="userCardId" placeholder="身份证号"
                   value="${cases.order.user.scardId}">
        </div>
        <div class="form-group">
            <label for="userPhone">客户电话：</label>
            <input type="text" class="form-control" id="userPhone" name="userPhone" placeholder="客户电话"
                   value="${cases.order.user.sphone}">
        </div>
        <div class="form-group">
            <label for="licenseNum">车牌号：</label>
            <input type="text" class="form-control" id="licenseNum" name="licenseNum" placeholder="车牌号"
                   value="${cases.cars.licenseNum}">
        </div>
        <div class="form-group">
            <label for="creditCard">银行卡号：</label>
            <input type="text" class="form-control" id="creditCard" name="creditCard" placeholder="输入银行卡号">
        </div>
        <div class="form-group">
            <label for="payMoney">赔付金额：</label>
            <input type="text" class="form-control" id="payMoney" name="payMoney" placeholder="赔付金额"
                   value="${cases.payAccount}">
        </div>
        <div class="form-group">
            <input type="hidden" class="form-control" id="empUuid" name="emp.euuId" placeholder="业务员"
                   value="${emp.euuId}">
        </div>
        <div class="form-group">
            <button type="submit" id="saveBtn" class="btn btn-success">提交</button>
            <button type="button" id="cancelBtn" class="btn btn-default">取消</button>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $("#saveBtn").on("click", function () {
        if (!check().form()) {
            return;
        }
        /*$.ajax({
            url: "/payBack/addPayBack.do",
            type: "POST",
            data: $("#addPayBackForm").serialize(),
            success: function (data) {
                layer.msg("受理赔付成功", {icon: 6});
                $("#cancelBtn").click();
            },
            error: function (data) {
                layer.msg("受理赔付失败", {icon: 5});
            }
        });*/
        $("#cancelBtn").click();
    });

    $("#cancelBtn").bind("click", function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.getUnPayCaseList();
        parent.layer.close(index);
    });
    /*表单校验*/
    function check() {
        return $("#addPayBackForm").validate({
            //规则
            rules: {
                caseId: {
                    required: true
                },
                payName: {
                    required: true
                },
                userCardId: {
                    required: true
                },
                userPhone: {
                    required: true
                }
                ,
                licenseNum: {
                    required: true
                }
                ,
                creditCard: {
                    required: true,
                    minlength:19,
                    maxlength:19
                }
                ,
                payMoney: {
                    required: true
                }
                ,
                empUuid: {
                    required: true
                }
            },
            messages: {
                caseId: {
                    required: ""
                },
                payName: {
                    required: ""
                },
                userCardId: {
                    required: ""
                },
                userPhone: {
                    required: ""
                }
                ,
                licenseNum: {
                    required: ""
                }
                ,
                creditCard: {
                    required: ""
                }
                ,
                payMoney: {
                    required: ""
                }
                ,
                empUuid: {
                    required: ""
                }
            }
        });
    }
</script>